package com.fzb.blog.model;

import java.io.Serializable;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

public class WebUser extends Model<WebUser> implements Serializable{
	public static final WebUser dao=new WebUser();
	
	public WebUser login(String userName,String password){
		String sql="select * from webuser where username=? and password=?";
		return (WebUser)findFirst(sql, new Object[]{userName,password});
	}
	public WebUser loginByPhone(String phone,String password){
		String sql="select * from webuser where phone=? and password=?";
		return (WebUser)findFirst(sql, new Object[]{phone,password});
	}
	public String getPasswordByName(String userName){
		String sql="select password from webuser where username=?";
		return (String)findFirst(sql,userName).get("password");
	}
	public boolean updatePassword(String userName,String password){
		String sql="update webuser set password=? where username=?";
		return Db.update(sql, password,userName)>0;
	}
}
